@extends('layouts.admin')
@section('content')

<script src="{{ asset('js/2019/jquery.query-object.js') }}"></script>


<div class="admin-home">
	<div class="panel panel-info my-container">

		<div class="panel-heading">
	    <h1 class="panel-title">
	      <ol class="breadcrumb">
	        <li><a href="{{ URL('admin') }}">后台首页</a></li>
	        <li class="active">文章列表</li>
	        <div class="right">
	          <a href="{{ url('admin')}}"  target="_blank">
	          </a>
	        </div>
	      </ol>
	      <div class="pull-right">
	      	<span class="btn btn-primary add" style="margin-top: -8px;">添加</span>
	      </div>
	    </h1>
	  </div>

	  {{--  --}}
	  <div class="panel-body">
	  	<div class="col-xs-3">
	  		<input type="text" class="form-control name" placeholder="输入文章名称" value="{{ $name }}">
	  	</div>
	  	<div class="col-xs-3">
	  		经典：
	  		<select class="form-control classic" style="display: inline-block;width: 80%;">
	  			@foreach ([-1=>'请选择',0=>'否',1=>'是'] as $key => $value)
	  				<option value="{{ $key }}"
						@if ( $classic == $key )
							selected 
						@endif
	  				>{{ $value }}</option>
	  			@endforeach
	  		</select>
	  	</div>
	  	<div class="col-xs-3">
	  		<span class="btn btn-info search">查询</span>
	  	</div>

			<div class="clear" style="height: 30px;"></div>
			<div class="col-xs-12">
				<table class="table">
					<thead>
						<tr>
							<th width="30%">名称</th>
							<th width="10%">浏览次数</th>
							<th width="10%">状态</th>
							<th width="10%">经典</th>
							<th width="20%">操作</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($all as $obj)
							<tr>
								<td>{{ $obj->name }}</td>
								<td>{{ $obj->count }}</td>
								<td>{{ $obj->enable ? "是" : "否" }}</td>
								<td>{{ $obj->classic ? "是" : "否" }}</td>
								<td><a href="{{ url('admin/cocktail/aticle/edit/'.$obj->id) }}">编辑</a></td>
							</tr>
						@endforeach
					</tbody>
				</table>
			</div>
			<div class="clear"></div>
			<div class="col-xs-12 text-right">
      	{{ $all->appends(['name'=>$name,'classic'=>$classic])->links() }}
			</div>

		

	  </div>

	</div>
	
</div>


<script>
$(".add").click(function(event) {
	/* Act on the event */
	window.location.href = '{{ url('admin/cocktail/aticle/add') }}';
});

$(".search").click(function(event) {
	/* Act on the event */
  window.location.search = $.query.set("name", $(".name").val() ).set("classic", $(".classic").val() ).set("page", 1);
});
</script>

@stop